import api from '@/libs/request'

/**
 * 分页查询当前店铺通知
 */
export const messagePage = (params: any) => {
    return api.get('/gruul-mall-carrier-pigeon/pigeon/notice', params)
}

/**
 * 根据id获取消息详情
 */
export const getMessageById = (messageId: string) => {
    return api.get(`/gruul-mall-carrier-pigeon/pigeon/notice/${messageId}`)
}

/**
 * 分页查询用户列表
 */
export const getMessageUsers = (keywords: string, page: any, shopId: string) => {
    return api.get(`/gruul-mall-carrier-pigeon/pigeon/platform-chat-room-messages/chat-rooms`, { ...page, keywords, shopId })
}
/**
 * 移动端商家后台未读消息总数
 */
export const getMessageTotal = () => {
    return api.get(`/gruul-mall-carrier-pigeon/pigeon/message/mobileTerminal/user/shop/unread/count`)
}
/**
 * 清除所有未读消息
 */
export const putClearMessage = () => {
    return api.put(`/gruul-mall-carrier-pigeon/pigeon/message/mobileTerminal/user/readUser`)
}
/**
 * 清除所有未读消息
 */
export const putClearOneMessage = (userId: string) => {
    return api.put(`/gruul-mall-carrier-pigeon/pigeon/message/mobileTerminal/user/readUser/${userId}`)
}

/**
 * 分页查询用户聊天记录
 */
export const getMessages = (userId: string, page: any) => {
    return api.get(`/gruul-mall-carrier-pigeon/pigeon/platform-chat-room-messages/chat-room`, { userId, ...page })
}

/**
 * 发送消息给用户
 * @param userId 用户id
 * @param data 消息体
 */
export const sendMessages = (data: any) => {
    return api.post(`/gruul-mall-carrier-pigeon/pigeon/platform-chat-room-messages/message`, data)
}
/**
 * 删除消息
 */
export const deletClearMessage = (userId: string) => {
    return api.put(`/gruul-mall-carrier-pigeon/pigeon/message/mobileTerminal/user/${userId}/deleteMessage`)
}
